#include <bits/stdc++.h>
using namespace std;
int main()
{
	int v[10000];
	int i, n, max = 0, left = 0, right = 0, 
			tempmax = 0, templeft = 0;
	cin >> n;
	for(i = 0; i < n; i++){
		cin >> v[i];
		tempmax += v[i];
		if(tempmax < 0){
			templeft = i + 1;
			tempmax = 0;
		}
		if(tempmax > max){
			max = tempmax;
			left = templeft;
			right = i;
		}
	}
	if(max < 0)
		cout << 0 << " " << v[0] << " " << v[n-1];
	else
		cout << max << " " << v[left] << " " << v[right];
	return 0;
} 
